/*
 * EtatRobotAVideFaceObstacle.cpp
 *
 *  Created on: 21 nov. 2011
 *      Author: jeddi
 */

#include "EtatRobotAVideFaceObstacle.h"
#include "EtatRobotEnChargeFaceObstacle.h"
#include "EtatRobotEnCharge.h"

EtatRobotAVideFaceObstacle* EtatRobotAVideFaceObstacle::instance = NULL;

EtatRobotAVideFaceObstacle* EtatRobotAVideFaceObstacle::getInstance(Robot* r){

	if(instance == NULL)
		instance = new EtatRobotAVideFaceObstacle(r);

	return instance;
}

void EtatRobotAVideFaceObstacle::saisir(Objet o) {
	r->setObjet(o);
	r->changerAncienEtat(this);
	r->changerEtat((EtatRobot*)EtatRobotEnChargeFaceObstacle::getInstance(r));
}

int EtatRobotAVideFaceObstacle::evaluerObstacle() {
	return r->getObstacle()->getHauteur();
}

void EtatRobotAVideFaceObstacle::tourner(string direction) {
	r->setDirection(direction);
	r->changerAncienEtat(this);
	r->changerEtat((EtatRobot*)EtatRobotEnCharge::getInstance(r));
}
